﻿@model QuanLyGiaoVuUI.Models.SinhVien.SinhVienViewModel
@{
    ViewBag.Title = "ThongTinCaNhan";
    Layout = "~/Views/Shared/_LayoutSinhVienClient2.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery-1.8.2.js")"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.9.1.js")"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Content/js/jsToastMessage/javascript/jquery.toastmessage.js")"></script>  
<style>
    .thongtinchung{
        margin:20px;
    }
    .infotext {
        width:100%;
    }
</style>
<div id="thongtin">
    <h2>Thông tin</h2>
    <div class="thongtinchung">
        <table class="gridtable" cellspacing="0" border="1" bordercolor="#000000" width="100%">
            <tr>
                <th>Sinh viên:</th>
                <td>@Model.HoTenSV</td>
            </tr>
            <tr>
                <th>MSSV:</th>
                <td>@Model.MaSinhVien</td>
            </tr>
            <tr>
                <th>Ngày Sinh:</th>
                <td>@Model.NgaySinh.ToShortDateString()</td>
            </tr>
            <tr>
                <th>Giới tính:</th>
                @if (Model.GioiTinh == 1)
                    { 
                        <td>Nam</td>
                    }
                 else
                 {
                    <td>Nữ</td>
                }
            </tr>
            <tr>
                <th>Quê Quán:</th><td>@Model.QueQuan</td>
            </tr>
            <tr><th>Địa Chỉ</th><td>@Model.DiaChi</td></tr>
            <tr><th>Email:</th><td>@Model.Email</td></tr>
        </table>
        <div><input type="button" id="btsuathongtin" value="Sửa thông tin" /></div>
    </div>
</div>

<div id="suathongtin">
    <h2>Thay đổi thông tin</h2>
    <div class="thongtinchung">
        <table class="gridtable" cellspacing="0" border="1" bordercolor="#000000" width="100%">
            <tr>
                <th>Sinh viên:</th>
                <td><input class="infotext" type="text" value="@Model.HoTenSV" id="HoTenSV" /></td>
            </tr>
            <tr>
                <th>Ngày Sinh:</th>
                <td><input class="date_picker" type="text" value="@Model.NgaySinh.ToShortDateString()" id="NgaySinh" /><span>(mm/dd/yyyy)</span></td>
            </tr>
            <tr>
                <th>Giới tính:</th>
                <td><select id="GioiTinh">
                @if (Model.GioiTinh == 1)
                    { 
                     <option value="1" selected="selected">Nam</option>   
                    <option value="0" >Nữ</option>   
                    }
                else
                {
                     <option value="1">Nam</option>   
                    <option value="0" selected="selected">Nữ</option>   
                }
                </select></td>
            </tr>
            <tr>
                <th>Quê Quán:</th><td><input class="infotext" type="text" value="@Model.QueQuan" id="QueQuan" /></td>
            </tr>
            <tr><th>Địa Chỉ</th><td><input class="infotext" type="text" value="@Model.DiaChi" id="DiaChi" /></td></tr>
            <tr><th>Email:</th><td><input class="infotext" type="text" value="@Model.Email" id="Email" /></td></tr>
        </table>
        <div>
            <span><input type="button" id="btcapnhat" value="Cập nhật" /></span>
            <span><input type="button" id="bthuy" value="Hủy" /></span>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#suathongtin").hide();
        $('#btsuathongtin').click(function () {
            $("#thongtin").hide(300);
            $("#suathongtin").show(300);
        });
        $('#bthuy').click(function () {
            $("#suathongtin").hide(300);
            $("#thongtin").show(300);
        });
        $('#btcapnhat').click(function () {
            var hoten = $('#HoTenSV').val();
            var ngaysinh = $('#NgaySinh').val();
            var gioitinh = $('#GioiTinh').val();
            var quequan = $('#QueQuan').val();
            var diachi = $('#DiaChi').val();
            var email = $('#Email').val();
            $.post("/SinhVien/ThongTinCaNhan", { HoTenSV: hoten, NgaySinh: ngaysinh, GioiTinh: gioitinh, QueQuan: quequan, DiaChi: diachi, Email: email }, function (data) {
                if (data.success == true) {
                    alert(data.message);                   
                    window.location = "/SinhVien/ThongTinCaNhan";
                }
                else {
                    alert(data.message);
                }
            });
        });
        $(".date_picker").datepicker();
    });
</script>